#!/usr/bin/env bash

# Test that tasks can use tools from idiomatic version files
# Issue: Since v2025.10.3, idiomatic_version_file_enable_tools stopped working in task execution

# First disable the parent /tmp/mise.toml experimental monorepo setting
# to avoid interference with this test
if [ -f /tmp/mise.toml ]; then
	mv /tmp/mise.toml /tmp/mise.toml.bak
	trap "mv /tmp/mise.toml.bak /tmp/mise.toml" EXIT
fi

# Create a .node-version file
echo "24.1.0" >.node-version

# Create mise.toml with idiomatic_version_file_enable_tools setting
cat >mise.toml <<'EOF'
[settings]
idiomatic_version_file_enable_tools = ["node"]

[tasks.call-node]
run = "which node"
EOF

# Trust the config
mise trust

# Install node from .node-version
mise install

# Run the task and verify it uses the mise-installed node
assert_contains "mise run call-node" ".local/share/mise/installs/node/24"
